package com.ztorn.fiscale.domain;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ztorn.common.core.annotation.Excel;
import com.ztorn.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 订单管理对象 fiscale_order
 *
 * @author ztorn
 * @date 2025-01-18
 */
public class FiscaleOrder extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 订单ID */
    private Long orderId;

    /** 订单号 */
    @Excel(name = "订单号")
    private String orderNo;

    /** 平台订单号 */
    @Excel(name = "平台订单号")
    private String platformOrderNo;

    /** 平台类型 */
    @Excel(name = "平台类型")
    private String platformType;

    /** 平台配置ID */
    private Long platformConfigId;

    /** 客户姓名 */
    @Excel(name = "客户姓名")
    private String customerName;

    /** 客户邮箱 */
    @Excel(name = "客户邮箱")
    private String customerEmail;

    /** 客户电话 */
    @Excel(name = "客户电话")
    private String customerPhone;

    /** 订单状态 */
    @Excel(name = "订单状态")
    private String orderStatus;

    /** 报关状态 */
    @Excel(name = "报关状态")
    private String customsStatus;

    /** 订单日期 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "订单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date orderDate;

    /** 订单总金额 */
    @Excel(name = "订单总金额")
    private BigDecimal totalAmount;

    /** 货币类型 */
    @Excel(name = "货币类型")
    private String currency;

    /** 收货地址 */
    private String shippingAddress;

    /** 账单地址 */
    private String billingAddress;

    /** 支付方式 */
    @Excel(name = "支付方式")
    private String paymentMethod;

    /** 支付状态 */
    @Excel(name = "支付状态")
    private String paymentStatus;

    /** 配送方式 */
    @Excel(name = "配送方式")
    private String shippingMethod;

    /** 物流跟踪号 */
    @Excel(name = "物流跟踪号")
    private String trackingNumber;

    /** 备注 */
    private String notes;

    /** 是否手动补录 */
    @Excel(name = "是否手动补录", readConverterExp = "0=否,1=是")
    private Integer isManual;

    /** 同步状态 */
    @Excel(name = "同步状态")
    private String syncStatus;

    /** 同步时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date syncTime;

    /** 订单商品明细 */
    private List<FiscaleOrderItem> orderItems;
    
    /** 查询用订单ID数组 */
    private Long[] orderIds;

    public void setOrderId(Long orderId)
    {
        this.orderId = orderId;
    }

    public Long getOrderId()
    {
        return orderId;
    }

    public void setOrderNo(String orderNo)
    {
        this.orderNo = orderNo;
    }

    public String getOrderNo()
    {
        return orderNo;
    }

    public void setPlatformOrderNo(String platformOrderNo)
    {
        this.platformOrderNo = platformOrderNo;
    }

    public String getPlatformOrderNo()
    {
        return platformOrderNo;
    }

    public void setPlatformType(String platformType)
    {
        this.platformType = platformType;
    }

    public String getPlatformType()
    {
        return platformType;
    }

    public void setPlatformConfigId(Long platformConfigId)
    {
        this.platformConfigId = platformConfigId;
    }

    public Long getPlatformConfigId()
    {
        return platformConfigId;
    }

    public void setCustomerName(String customerName)
    {
        this.customerName = customerName;
    }

    public String getCustomerName()
    {
        return customerName;
    }

    public void setCustomerEmail(String customerEmail)
    {
        this.customerEmail = customerEmail;
    }

    public String getCustomerEmail()
    {
        return customerEmail;
    }

    public void setCustomerPhone(String customerPhone)
    {
        this.customerPhone = customerPhone;
    }

    public String getCustomerPhone()
    {
        return customerPhone;
    }

    public void setOrderStatus(String orderStatus)
    {
        this.orderStatus = orderStatus;
    }

    public String getOrderStatus()
    {
        return orderStatus;
    }

    public void setCustomsStatus(String customsStatus)
    {
        this.customsStatus = customsStatus;
    }

    public String getCustomsStatus()
    {
        return customsStatus;
    }

    public void setOrderDate(Date orderDate)
    {
        this.orderDate = orderDate;
    }

    public Date getOrderDate()
    {
        return orderDate;
    }

    public void setTotalAmount(BigDecimal totalAmount)
    {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getTotalAmount()
    {
        return totalAmount;
    }

    public void setCurrency(String currency)
    {
        this.currency = currency;
    }

    public String getCurrency()
    {
        return currency;
    }

    public void setShippingAddress(String shippingAddress)
    {
        this.shippingAddress = shippingAddress;
    }

    public String getShippingAddress()
    {
        return shippingAddress;
    }

    public void setBillingAddress(String billingAddress)
    {
        this.billingAddress = billingAddress;
    }

    public String getBillingAddress()
    {
        return billingAddress;
    }

    public void setPaymentMethod(String paymentMethod)
    {
        this.paymentMethod = paymentMethod;
    }

    public String getPaymentMethod()
    {
        return paymentMethod;
    }

    public void setPaymentStatus(String paymentStatus)
    {
        this.paymentStatus = paymentStatus;
    }

    public String getPaymentStatus()
    {
        return paymentStatus;
    }

    public void setShippingMethod(String shippingMethod)
    {
        this.shippingMethod = shippingMethod;
    }

    public String getShippingMethod()
    {
        return shippingMethod;
    }

    public void setTrackingNumber(String trackingNumber)
    {
        this.trackingNumber = trackingNumber;
    }

    public String getTrackingNumber()
    {
        return trackingNumber;
    }

    public void setNotes(String notes)
    {
        this.notes = notes;
    }

    public String getNotes()
    {
        return notes;
    }

    public void setIsManual(Integer isManual)
    {
        this.isManual = isManual;
    }

    public Integer getIsManual()
    {
        return isManual;
    }

    public void setSyncStatus(String syncStatus)
    {
        this.syncStatus = syncStatus;
    }

    public String getSyncStatus()
    {
        return syncStatus;
    }

    public void setSyncTime(Date syncTime)
    {
        this.syncTime = syncTime;
    }

    public Date getSyncTime()
    {
        return syncTime;
    }

    public List<FiscaleOrderItem> getOrderItems()
    {
        return orderItems;
    }

    public void setOrderItems(List<FiscaleOrderItem> orderItems)
    {
        this.orderItems = orderItems;
    }

    public Long[] getOrderIds()
    {
        return orderIds;
    }

    public void setOrderIds(Long[] orderIds)
    {
        this.orderIds = orderIds;
    }

    /**
     * 计算订单的总重量
     *
     * @return 总重量
     */
    public java.math.BigDecimal getTotalWeight()
    {
        if (orderItems == null || orderItems.isEmpty()) {
            return java.math.BigDecimal.ZERO;
        }
        java.math.BigDecimal totalWeight = java.math.BigDecimal.ZERO;
        for (FiscaleOrderItem item : orderItems) {
            if (item.getWeight() != null) {
                totalWeight = totalWeight.add(item.getWeight());
            }
        }
        return totalWeight;
    }

    /**
     * 计算订单的总数量
     *
     * @return 总数量
     */
    public Long getTotalQuantity()
    {
        if (orderItems == null || orderItems.isEmpty()) {
            return 0L;
        }
        long totalQuantity = 0L;
        for (FiscaleOrderItem item : orderItems) {
            if (item.getQuantity() != null) {
                totalQuantity += item.getQuantity();
            }
        }
        return totalQuantity;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("orderId", getOrderId())
            .append("orderNo", getOrderNo())
            .append("platformOrderNo", getPlatformOrderNo())
            .append("platformType", getPlatformType())
            .append("platformConfigId", getPlatformConfigId())
            .append("customerName", getCustomerName())
            .append("customerEmail", getCustomerEmail())
            .append("customerPhone", getCustomerPhone())
            .append("orderStatus", getOrderStatus())
            .append("customsStatus", getCustomsStatus())
            .append("orderDate", getOrderDate())
            .append("totalAmount", getTotalAmount())
            .append("currency", getCurrency())
            .append("shippingAddress", getShippingAddress())
            .append("billingAddress", getBillingAddress())
            .append("paymentMethod", getPaymentMethod())
            .append("paymentStatus", getPaymentStatus())
            .append("shippingMethod", getShippingMethod())
            .append("trackingNumber", getTrackingNumber())
            .append("notes", getNotes())
            .append("isManual", getIsManual())
            .append("syncStatus", getSyncStatus())
            .append("syncTime", getSyncTime())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}
